package aiku.numericalcontroloa.Controller.EmployeeAttendance;

import aiku.numericalcontroloa.Base.Utils.Result;
import aiku.numericalcontroloa.Model.Dto.EmployeeAttendance.AttendanceDto;
import aiku.numericalcontroloa.Service.EmployeeAttendance.AttendanceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 黄广庭
 * @Date 2024/2/26 16:27
 */
@RestController
@RequestMapping("/attendance")
@Slf4j
public class AttendanceController {
    private final AttendanceService attendanceService;

    public AttendanceController(AttendanceService attendanceService) {
        this.attendanceService = attendanceService;
    }

    /**
     *
     * 添加出勤记录
     * @param attendanceDto
     * @return
     */
    @PostMapping("/addAttendance")
    public Result addAttendance(@RequestBody AttendanceDto attendanceDto){
        return attendanceService.addAttendance(attendanceDto);
    }

//    /**
//     * 删除
//     * @return
//     */
//    @PostMapping("/deleteAttendance")
//    public Result deleteAttendance(){
//        return attendanceService.deleteAttendance();
//    }

    /**
     * 修改，打卡
     * @return
     */
    @PostMapping("/updateAttendance")
    public Result updateAttendance(@RequestBody AttendanceDto attendanceDto){
        return attendanceService.updateAttendance(attendanceDto);
    }

    /**
     * 获取出勤列表（总计）
     * @param attendanceDto
     * @return
     */
    @PostMapping("/getAttendanceList")
    public Result getAttendanceList(@RequestBody AttendanceDto attendanceDto){
        return attendanceService.getAttendanceList(attendanceDto);
    }

    /**
     * 获取用户个人出勤记录列表
     * @param attendanceDto
     * @return
     */
    @PostMapping("/getUserAttendanceList")
    public Result getUserAttendanceList(@RequestBody AttendanceDto attendanceDto){
        return attendanceService.getUserAttendanceList(attendanceDto);
    }

    /**
     * 获取个人某天出勤记录
     * @param attendanceDto
     * @return
     */
    @PostMapping("/getUserAttendance")
    public Result getUserAttendance(@RequestBody AttendanceDto attendanceDto){
        return attendanceService.getUserAttendance(attendanceDto);
    }

    @GetMapping("/Excel")
    public void exportExcel(String filename) {
        attendanceService.exportExcel(filename);
    }

}
